"""
演示常见魔术方法的使用
"""
class Student:
    def __init__(self,name,age):
        self.name = name
        self.age = age

# __str__魔术方法
#     def __str__(self):
#         return f"Student name:{self.name},age: {self.age} "
# stu = Student("周杰轮",31,69)
# print(stu)
# print(str(stu))
# __lt__小于符号比较方法
#     def __lt__(self, other):
#         return self.age < other.age
# stu1 = Student("周杰轮",31)
# stu2 = Student("林俊节",36)
# print(stu1<stu2)
# print(stu1>stu2)

# __le__小于等于比较运算符
#     def __le__(self, other):
#         return self.age <= other.age
# stu1 = Student("林俊节",36)
# stu2 = Student("周杰轮",36)
# print(stu1==stu2) # 默认比较内存地址
# print(stu1<=stu2)
# print(stu1>=stu2)
# __eq__函数方法
    def __eq__(self,other):
        return self.age == other.age
stu1 = Student("林俊节",36)
stu2 = Student("周杰轮",36)
print(stu1 == stu2)
